package com.apollow.oschina.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.apollow.oschina.R;

import cn.bingoogolapple.qrcode.core.QRCodeView;
import cn.bingoogolapple.qrcode.zxing.ZXingView;

/**
 * Created by Dragon on 2017/1/19.
 */
public class ScanActivity extends AppCompatActivity implements QRCodeView.Delegate{
    private ZXingView mQRCodeView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scan);

        mQRCodeView = (ZXingView) findViewById(R.id.zxingview);
        mQRCodeView.startSpot();
        mQRCodeView.setResultHandler(this);//这个参数是一个Delegate接口，已经在本类实现了，也可以在这里进行实现
    }

    @Override
    public void onScanQRCodeSuccess(String result) {
        /*if (result.contains("csdn.net")) {
            startWebViewForResult(result, true, "", IntentKey.BACK);
        }*/
        mQRCodeView.startCamera();
        mQRCodeView.startSpot();
        mQRCodeView.setResultHandler(this);
    }

    @Override
    public void onScanQRCodeOpenCameraError() {
        Log.e("heima11", "打开相机出错");
    }
}
